function [ outEFG ] = wrapperCHINO( xNodes, xSamples, optEFG)
%WRAPPEREFG Returns a wrapper of the EFG aproximants and associated 
%   gradients.
%
%   INPUT:
%   xNodes      :   Set of nodes.
%   xSamples    :   Set of samples points.
%   optEFG      :   Wrapper structure that contains rho, poliBaseType 
%                   and order fields.  
%
%   OUTPUT
%   outEFG.p_samp   :   Shape functions at each sample point.
%   outEFG.dp_samp  :   Gradient of the shape functions at each sample point.


rho             = optEFG.rho;

totalNodes      = size(xNodes,1);
totalSamples    = size(xSamples,1);

samplesShapeFunction     = cell(1, totalSamples);
gradSamplesShapeFunction = cell(1, totalSamples);
form = 'cubic_spline';

for indexSample = 1 : totalSamples
    pt = xSamples(indexSample,:);    
    %[index] = define_support(xNodes,pt,100);
    index = optEFG.s_near{indexSample};
    
    [ p_samp dpx_samp dpy_samp ] =...
        MLS_ShapeFunction(pt, index, xNodes, ones(totalNodes,1)*rho, form);
    
    p_samp = p_samp';
    dpx_samp = dpx_samp';
    dpy_samp = dpy_samp';
    ps =   p_samp;
    dps = [ dpx_samp(:) , dpy_samp(:)];
    samplesShapeFunction{indexSample} = ps;
    gradSamplesShapeFunction{indexSample} = dps;
end

outEFG.p_samp = samplesShapeFunction;
outEFG.dp_samp = gradSamplesShapeFunction;
end